/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

/**
 *
 * @author alumnos
 */
import beans.BeanProformaCabecera;
import beans.BeanProformaDetalle;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DAOProforma {

    PreparedStatement ptmt = null;
    ResultSet resulSet = null;
    Connection conexion = null;

    private Connection getConnection() throws SQLException {
        Connection conn;
        //BDConexFactory fact = new BDConexFactory(dataSource);
        conn = BDConexFactory.getInstance().getConnection();
        return conn;
    }

    public boolean InsertarProforma(BeanProformaCabecera objProforma) {
        boolean Resultado=false;

        try {

            conexion = getConnection();

            String sql = "insert into Proforma(IdProforma,FechaProforma,TipoDocumento,RazonSocial,TipoComprobante)values(?,?,?,?,?)";

            ptmt = conexion.prepareStatement(sql);

            //aca hacer la insercion :D
            ptmt.setLong(1, objProforma.getIdProforma());
            ptmt.setDate(2,objProforma.getFecha());
            ptmt.setString(3, objProforma.getTipoDocumento());
            ptmt.setString(4,objProforma.getRazonSocial());
            ptmt.setString(5,objProforma.getTipoComprobante());            

            ptmt.executeUpdate();
            Resultado=true;
                    
        } catch (Exception e) {
            Resultado=false;
        } finally {

            try {
                if (resulSet != null) {
                    resulSet.close();
                }
            } catch (SQLException e) {
                System.out.println("DAOArancel buscarArancelBD()"
                        + e.getMessage());
            } finally {

                try {
                    if (ptmt != null) {
                        ptmt.close();
                    }
                } catch (SQLException e) {
                    System.out.println("DAOArancel buscarArancelBD()"
                            + e.getMessage());


                }
                try {
                    if (conexion != null) {
                        conexion.close();
                        System.out.println("Cerrando conexion a  Base de Datos");
                    }
                } catch (SQLException e) {
                    System.out.println("DAOArancel buscarArancelBD()"
                            + e.getMessage());
                }
            }
            return Resultado;
        }

    }
}
